//rename the property
//modify constructor 
import java.util.*;

public class GameLot {
	
	protected String name;
	protected int price;
	protected int mortgageValue;	// value used to mortgage property
	//private int location;
	private String type;
	private int ownedBy; // tells which player owns the lot:  0 - nobody, 1 - p1, 2  - p2, etc.
	private boolean isMortgaged;
	
	//for properties
	private String color;
	private int numHouses;		// from 0 to 4
	private boolean hasHotel;		// we can build only 1 hotel

	private int buildCost;		//build cost for 1 house is same as hotel
	private int rentValue;		// rent value with no upgrades
	private int rent1House;		// rent value with 1 house
	private int rent2Houses;	// rent value with 2 houses
	private int rent3Houses;	// rent value with 3 houses
	private int rent4Houses;	// rent value with 4 houses
	private int rentHotel;		// rent value with a hotel
	
	//Player owner;
	
	
	/***********CONSTRUCTOR************/
	public GameLot(String name){
		
		setName(name);//set the name
		this.setColorByName();
		this.numHouses = 0;
		this.hasHotel = false;
		ownedBy = 0;
		this.isMortgaged = false;
		//Now initializing the price, mortgage value, build cost & rent value
		//based on the name of each property
		if(name == "MediterraneanAve"){
    		color = "DarkPurple";
    		setType("property");
    		setPrice(60);
    		setMortgageValue(30);
    		setBuildCost(50);
    		setRentValue(2, 10, 30, 90, 160, 250);
    	}
		else if(name == "BalticAve"){
			color = "DarkPurple";
			setType("property");
    		setPrice(60);
    		setMortgageValue(30);
    		setBuildCost(50);
    		setRentValue(4, 20, 60, 180, 320, 450);
		}
    	else if(name == "OrientalAve" || name == "VermontAve"){
    		color = "LightBlue";
    		setType("property");
    		setPrice(100);
    		setMortgageValue(50);
    		setBuildCost(50);
    		setRentValue(6, 30, 90, 270, 400, 550);	
    	}
    	else if(name == "ConnecticutAve"){
    		color = "LightBlue";
    		setType("property");
    		setPrice(120);
    		setMortgageValue(60);
    		setBuildCost(50);
    		setRentValue(8, 40, 100, 300, 450, 600);	
    	}
    	else if(name == "StCharlesPlace" || name == "StatesAve"){
    		color = "LightPurple";
    		setType("property");
    		setPrice(140);
    		setMortgageValue(70);
    		setBuildCost(100);
    		setRentValue(10, 50, 150, 450, 625, 750);
    	}
    	else if(name == "VirginiaAve"){
    		color = "LightPurple";
    		setType("property");
    		setPrice(160);
    		setMortgageValue(80);
    		setBuildCost(100);
    		setRentValue(12, 60, 180, 500, 700, 900);
    	}
    	else if(name == "StJamesPlace" || name == "TennesseeAve"){
    		color = "Orange";
    		setType("property");
    		setPrice(180);
    		setMortgageValue(90);
    		setBuildCost(100);
    		setRentValue(14, 70, 200, 550, 750, 950);
    	}
    	else if(name == "NewYorkAve"){
    		color = "Orange";
    		setType("property");
    		setPrice(200);
    		setMortgageValue(100);
    		setBuildCost(100);
    		setRentValue(16, 80, 220, 600, 800, 1000);
    	}
    	else if(name == "KentuckyAve" || name == "IndianaAve"){
    		color = "Red";
    		setType("property");
    		setPrice(220);
    		setMortgageValue(110);
    		setBuildCost(150);
    		setRentValue(18, 90, 250, 700, 875, 1050);
    	}
    	else if(name == "IllinoisAve"){
    		color = "Red";
    		setType("property");
    		setPrice(240);
    		setMortgageValue(120);
    		setBuildCost(150);
    		setRentValue(20, 100, 300, 750, 925, 1100);
    	}
    	else if(name == "AtlanticAve" || name == "VentnorAve"){
    		color = "Yellow";
    		setType("property");
    		setPrice(260);
    		setMortgageValue(130);
    		setBuildCost(150);
    		setRentValue(22, 110, 330, 800, 975, 1150);
    	}
    	else if(name == "MarvinGardens"){
    		color = "Yellow";
    		setType("property");
    		setPrice(280);
    		setMortgageValue(140);
    		setBuildCost(150);
    		setRentValue(24, 120, 360, 850, 1025, 1200);
    	}
    	else if(name == "PacificAve" || name == "NorthCarolinaAve"){
    		color = "Green";
    		setType("property");
    		setPrice(300);
    		setMortgageValue(150);
    		setBuildCost(130);
    		setRentValue(26, 130, 390, 900, 1100, 1275);
    	}
    	else if(name == "PennsylvaniaAve"){
    		color = "Green";
    		setType("property");
    		setPrice(320);
    		setMortgageValue(160);
    		setBuildCost(200);
    		setRentValue(28, 150, 450, 1000, 1200, 1400);
    	}
    	else if(name == "ParkPlace"){
    		color = "DarkBlue";
    		setType("property");
    		setPrice(350);
    		setMortgageValue(175);
    		setBuildCost(200);
    		setRentValue(35, 175, 500, 1100, 1300, 1500);
    	}
    	else if(name == "Boardwalk"){
    		color = "DarkBlue";
    		setType("property");
    		setPrice(400);
    		setMortgageValue(200);
    		setBuildCost(200);
    		setRentValue(50, 200, 600, 1400, 1700, 2000);
    	}
        else if(name == "ReadingRailroad" || name == "B&ORailroad" || name == "ShortLineRailroad" || name == "PennsylvaniaRailroad")
        {
               color = "Black";
               type = "railroad";
               setPrice(200);
               setMortgageValue(100);   
        }
        else if(name == "Chance")
        {
            type = "chance";
        }
        else if(name == "CommunityChest")
        {
            type = "communitychest";
        }
        else if(name == "IncomeTax" || name == "LuxuryTax")
        {
            type = "tax";
        }
        else if(name == "Go" || name == "Jail" || name == "FreeParking" || name == "GoToJail")
        {
            type = "corner";
        }
        else if(name == "WaterWorks" || name == "ElectricCompany")
        {
            type = "utility";
            color = "White";
            setPrice(150);
            setMortgageValue(75);
        }
		
	}
	public void setName(String propertyName){
		name = propertyName;
	}

	public void setType(String propertyType){
		type = propertyType;
	}
	
	public String getType()
	{
		return type;
	}
	public int getOwnedBy()
	{
		return ownedBy;
	}
	
	public void setOwnedBy(int playerNum)
	{
		ownedBy = playerNum;
	}

	public void setMortgageValue(int mv){
		mortgageValue =  mv;
	}
	public boolean isMortgaged(){
		return isMortgaged;
	}
	public int getMortgageValue(){
		return this.mortgageValue;
	}
	
	public String getName()
	{
		return name;
	} // end getName
	public int getPrice()
	{
		return price;
	} // end getPrice
	public void setPrice(int p){
		price = p;
	}
	//setColorByName() -- set its color according to its name
	public void setColorByName(){
		if(name == "MediterraneanAve" || name == "BalticAve"){
    		color = "DarkPurple";
    	}
    	else if(name == "OrientalAve" || name == "VermontAve" || name == "ConnecticutAve"){
    		color = "LightBlue";
    	}
    	else if(name == "StCharlesPlace" || name == "StatesAve" || name == "VirginiaAve"){
    		color = "LightPurple";
    	}
    	else if(name == "StJamesPlace" || name == "TennesseeAve" || name == "NewYorkAve"){
    		color = "Orange";
    	}
    	else if(name == "KentuckyAve" || name == "IndianaAve" || name == "IllinoisAve"){
    		color = "Red";
    	}
    	else if(name == "AtlanticAve" || name == "VentnorAve" || name == "MarvinGardens"){
    		color = "Yellow";
    	}
    	else if(name == "PacificAve" || name == "NorthCarolinaAve" || name == "PennsylvaniaAve"){
    		color = "Green";
    	}
    	else if(name == "ParkPlace" || name == "Boardwalk"){
    		color = "DarkBlue";
    	}
	}
	//getnumHouses() -- returns the num of houses built
	public int getNumHouses(){
		return numHouses;
	}
	//hotelOwned() -- return 1 if the hotel is already built
	public boolean hotelOwned(){
		return hasHotel;
	}
	private void setBuildCost(int bc){
		buildCost = bc;
	}
	public int getBuildCost(){
		return buildCost;
	}
	public void setRentValue(int noHouse, int w1House, int w2Houses, 
			int w3Houses, int w4Houses, int wHotel){
		rentValue = noHouse;
		this.rent1House = w1House;
		this.rent2Houses = w2Houses;
		this.rent3Houses = w3Houses;
		this.rent4Houses = w4Houses;
		this.rentHotel = wHotel;
	}
	//getRentValue() -- return the amount of rent based on the
	//the number of houses and hotel
	public int getRentValue(){
		if(this.hasHotel == true){
			return rentHotel;
		}
		else{
			if(this.numHouses == 0)
				return rentValue;
			else if(this.numHouses == 1)
				return this.rent1House;
			else if(this.numHouses == 2)
				return this.rent2Houses;
			else if(this.numHouses == 3)
				return this.rent3Houses;
			else
				return this.rent4Houses;
		}
	}
	public String getColor(){
		return this.color;
	}
	public void addHouse(int numNewHouse){
		numHouses += numNewHouse;
	}
	public void removeHouse(int numHouseRemoved){
		numHouses -= numHouseRemoved;
	}
	public void buildHotel(){
		this.hasHotel = true;
	}
	public void removeHotel(){
		this.hasHotel = false;
	}
	public void mortgage(){
		this.isMortgaged = true;
	}
	public void unmortgage(){
		
		this.isMortgaged = false;
	}
}
